package Tests;

import java.util.Iterator;

import system.BlogSystem;
import bean.BlogBean;
import bean.UserBean;
import dao.BlogDAO;
import dao.DAO;
import dao.UserDAO;

public class UserStoryFacade6 {

	private BlogSystem system = BlogSystem.getInstance();
	private DAO<UserBean> userDAO = UserDAO.getInstance();
	private DAO<BlogBean> blogDAO = BlogDAO.getInstance();

	public String todaysDate() {
		return system.todaysDate();
	}

	public void cleanPersistence() {
		Iterator<UserBean> users = userDAO.list().iterator();

		while (users.hasNext()) {
			UserBean anotherUser = users.next();
			userDAO.delete(anotherUser);
		}

		Iterator<BlogBean> blogs = blogDAO.list().iterator();

		while (blogs.hasNext()) {
			BlogBean anotherBlog = blogs.next();
			blogDAO.delete(anotherBlog);
		}
		system.finalize();
	}

	public void createProfile(String login, String senha, String nome_exibicao,
			String email, String sexo, String dataNasc, String endereco,
			String interesses, String quem_sou_eu, String filmes,
			String musicas, String livros) throws Exception {

		system.createUser(login, senha, nome_exibicao, email, sexo, dataNasc,
				endereco, interesses, quem_sou_eu, filmes, musicas, livros);
	}

	public String logon(String login, String senha) throws Exception {
		return system.login(login, senha);

	}

	public String createBlog(String sessionId, String title, String description)
			throws Exception {
		return system.createBlog(sessionId, title, description);
	}


	public String createPost(String sessionId, String blogId, String title,
			String text) throws Exception {
		return system.createPost(sessionId, blogId, title, text);

	}

	public String attachSound(String sessionId, String postId,
			String description, String data) throws Exception {
		return system.attachSound(sessionId, postId, description, data);
	}

	public String attachMovie(String sessionId, String postId,
			String description, String data) throws Exception {
		return system.attachMovie(sessionId, postId, description, data);
	}

	public String attachPicture(String sessionId, String postId,
			String description, String data) throws Exception {
		return system.attachPicture(sessionId, postId, description, data);
	}

	public String getPostInformation(String postId, String atributo)
			throws Exception {
		return system.getPostInformation(postId, atributo);
	}

	public String getNumberOfSounds(String postId) throws Exception{
		return String.valueOf(BlogSystem.getInstance().getNumberOfSoundsOfPost(postId));
	}

	public String getNumberOfMovies(String postId) throws Exception{
		return String.valueOf(BlogSystem.getInstance().getNumberOfMoviesOfPost(postId));

	}

	public String getNumberOfPictures(String postId) throws Exception{
		return String.valueOf(BlogSystem.getInstance().getNumberOfPicturesOfPost(postId));
	}


	public String getSound(String postId, long index) throws Exception {
		return system.getSound(postId, index);
	}

	public String getSoundDescription(String audioId) throws Exception {
		return system.getMediaDescription(audioId);

	}

	public String getSoundData(String audioId) throws Exception {
		return system.getMediaData(audioId);

	}

	public String getMovie(String postId, long index) throws Exception {
		return system.getMovie(postId, index);

	}

	public String getMovieDescription(String videoId) throws Exception {
		return system.getMediaDescription(videoId);

	}

	public String getMovieData(String videoId) throws Exception {
		return system.getMediaData(videoId);

	}
	
	public String getPictureDescription(String imageId) throws Exception{
		return system.getMediaDescription(imageId); 

	}
	

	public String getPictureData(String imageId) throws Exception{
		return system.getMediaData(imageId); 

	}

	public String getPicture(String postId, long index) throws Exception {
		return system.getPicture(postId, index);

	}
	
	public void logoff(String idSession) throws Exception{
		system.logout(idSession);
	}
	public void saveData(){
		
	}
}
